package ru.ifmo.mlarinsky.classificator.map;

import java.util.ArrayList;
import java.util.List;
import ru.ifmo.mlarinsky.classificator.providers.InstructionsProvider;

public class SomMap extends ArrayList<MapNode> {
    private final InstructionsProvider instructionsProvider;

    public SomMap(List<MapNode> map, InstructionsProvider provider) {
        super(map.size());
        this.instructionsProvider = provider;

        addAll(map);
    }

    public InstructionsProvider getInstructionsProvider() {
        return instructionsProvider;
    }

    public int getXDimension() {
        return instructionsProvider.getXDimension();
    }

    public int getYDimension() {
        return instructionsProvider.getYDimension();
    }

    public String getName() {
        return instructionsProvider.getOutputMapName();
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder("Map " + getName() + ":\n");

        for (MapNode node : this) {
            sb.append(node.getLabel()).append(" -> [").append(node.getX()).append(", ").
                    append(node.getY()).append("]\n");
        }

        return sb.toString();
    }
}
